<%--
  - Author		:	이 영호(Youngho Lee)	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript">
			$(function(){
				$(".popupWrap").draggable({ cursor: "pointer", handle: ".pTitle" });
				<c:if test="${not empty vertification && param.fAct eq 'add'}">
					$(".pApplet").show();					
				</c:if>
			});
			
			function validation(){
				try{
					with(document.frm){
						if((aid.value).replace(/\s/g, '') == ""){
							alert("애플릿 AID를 입력하여 주십시요.");
							aid.focus();
							return false;
						}
						if((capFile.value).replace(/\s/g, '') == ""){
							alert("CAP 파일을 선택하여 주십시요.");
							capFile.focus();
							return false;
						}
						if($(".chkDevice:checked").length == 0){
							alert("하나 이상의 TEST 단말을 선택하여 주십시요.");
							return false;
						}
					}
				}catch(err){
					alert(err);
					return false;
				}
				
				if(! confirm("애플릿 검증신청을 하시겠습니까?")){
					return false;
				}

				return true;
			}
			
			function selDevice(){
				var devices = "";
				var f_devices = "";
				for(var i=0;i<$(".chkDevice:checked").length;i++){
					if(i!=0){
						devices+=",";
					}else{
						f_devices = $(".chkDevice:checked").eq(i).val();
					}
					devices += $(".chkDevice:checked").eq(i).val();
				}
				if(i > 1){
					$("#testDeviceTxt").val(f_devices + "외 "+ parseInt(i-1) + "종");
				}else{
					$("#testDeviceTxt").val(f_devices);
				}
				document.frm.testDevice.value=devices;
				$(".pDevice").hide();
			}

		</script>
	</head>
	<body>
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="contMenuTitle">
					<img src="<c:url value="${dirImages}/subtit_02_1.gif" />" title="애플릿 검증 신청" alt="애플릿 검증 신청">
				</div>
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="검증신청" alt="검증신청" > 검증신청
				</div>
				<form name="frm" method="post" enctype="multipart/form-data" action="<c:url value="/request/submit.do" />" onsubmit="return validation();">
					<input type="hidden" name="type" value="1">
					<table class="formTbl">
						<tbody>
							<tr>
								<th>신청기관명</th>
								<td>
									<input type="hidden" name="bizName" value="<c:out value="${sessionScope.userBizNm}" />" />
									<c:out value="${sessionScope.userBizNm}" />
									<%--
									<select name="bizName" title="신청기관명" alt="신청기관명">
										<option value="SKT" <c:if test="${vertification.bizName eq 'SKT'}"> selected="selected" </c:if>>SKT</option>
										<option value="KT" <c:if test="${vertification.bizName eq 'KT'}"> selected="selected" </c:if>>KT</option>
										<option value="LGU+" <c:if test="${vertification.bizName eq 'LGU+'}"> selected="selected" </c:if>>LGU+</option>
									</select>
									--%>
								</td>
								<th>신청자 ID</th>
								<td><c:out value="${sessionScope.userId}" /></td>
							</tr>
							<tr>
								<th>애플릿 AID</th>
								<td>
									<input type="text" name="aid" title="애플릿 AID" alt="애플릿 AID" value="${vertification.aid}" />
								</td>
								<th>검증기간</th>
								<td>
									<jsp:useBean id="now" class="java.util.Date" />
									<fmt:formatDate var="now" value="${now}" pattern="yyyy/MM/dd" /> 
									${now}<br />
									&nbsp;&nbsp;&nbsp;(3영업일 이내)
								</td>
							</tr>
							<tr>
								<th>TEST 단말</th>
								<td>
									<img class="btn"  src="<c:url value="${dirImages}/bt_mobile_select.gif" />" title="단말 선택" alt="단말 선택" onclick="javascript:$('.pDevice').show();" />
									<input type="text" name="testDeviceTxt" readonly="readonly" title="TEST 단말" alt="TEST 단말" value="${vertification.testDevice}" />
									<input type="hidden" name="testDevice" readonly="readonly" title="TEST 단말" alt="TEST 단말" value="${vertification.testDevice}" />
								</td>
								<th>CAP 파일</th>
								<td>
									<input type="file" name="capFile" title="CAP 파일" alt="CAP 파일" />
									<input type="hidden" name="cap" title="CAP 파일" alt="CAP 파일" value="${vertification.cap}" />
								</td>
							</tr>
						</tbody>
					</table>
					<div class="btnWrap rightBtnWrap">
						<c:choose>
							<c:when test="${param.fAct eq 'modify'}">
								<input type="hidden" name="fAct" value="modify">
								<input type="hidden" name="idx" value="${vertification.idx}">
								<input type="hidden" name="completedTime" value="Y">
								<input type="submit" class="btn btn_retestify" alt="재검증신청" title="재검증신청" value="">
							</c:when>
							<c:otherwise>
								<input type="hidden" name="fAct" value="add">
								<input type="submit" class="btn btn_save" alt="저장하기" title="저장하기" value="">
							</c:otherwise>
						</c:choose>
					</div>
				</form>
			</div>
		</div>
		<div class="popupWrap pDevice" style="display: none;">
			<div class="pTitle">
				단말기 선택
				<div class="pClose btn" onclick="javascript:$('.pDevice').hide();"></div>
			</div>
			<div class="pCont" style="height: 300px; overflow-y: scroll; ">
				<table class="listTbl">
					<thead>
						<tr>
							<th>선택</th>
							<th>제조사</th>
							<th>모델명</th>
							<th class="lastTh">통신사</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${testDeviceList}" var="testDevice">
							<tr>
								<td>
									<input type="checkbox" name="chkDevice" class="chkDevice" <c:if test="${fn:contains(vertification.testDevice, fn:split(testDevice.value,',')[1])}"> checked="checked" </c:if> value="${fn:split(testDevice.value,',')[1]}" />
								</td>
								<td>${fn:split(testDevice.value,',')[0]}</td>
								<td>${fn:split(testDevice.value,',')[1]}</td>
								<td>${fn:split(testDevice.value,',')[2]}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<div class="btnWrap centerBtnWrap">
				<input type="button" class="btn btn_apply2" alt="적용" title="적용" onclick="javascript:selDevice();">
			</div>
		</div>
		<div class="popupWrap pApplet" style="display: none;">
			<div class="pTitle">
				애플릿 검증신청
				<div class="pClose btn" onclick="javascript:$('.pApplet').hide();"></div>
			</div>
			<div class="pCont">
				<p>
					신청기관명 : <font id="bizName">${vertification.bizName}</font><br />
					애플릿 AID : <font id="aid">${vertification.aid}</font><br />
					TEST 단말 : <font id="testDevice">${vertification.testDevice}</font><br />
					<fmt:message key="file.capFile.viewUrl" var="viewUrl" />
					CAP 파일 : <a href="${vertification.cap}" target="_blank"><font id="capFile">CAP 파일 다운로드</font></a><br />
					완료 예정일자 : <font id="completedTime">${fn:split(vertification.completedTime, ' ')[0]}</font>
				</p>
			</div>
			<div class="btnWrap centerBtnWrap">
				<input type="button" class="btn btn_apply" alt="신청완료" title="신청완료"  onclick="javascript:$('.pApplet').hide();">
				<a href="<c:url value="/result/list.do" />"><input type="button" class="btn btn_effect" alt="결과 조회로 이동" title="결과 조회로 이동"></a>
			</div>
		</div>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
	</body>
</html> 